package com.myhexin.demo.plugin.message;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.ServiceLoader;

/**
 * @author zhangzhonglv@myhexin.com
 * @date 2025/7/12
 */
public class PluginFactory {

    public static void main(String[] args) {
        ServiceLoader<MessagePlugin> serviceLoader = ServiceLoader.load(MessagePlugin.class);
        Iterator<MessagePlugin> iterator = serviceLoader.iterator();
        Map<String, String> map = new HashMap<>();
        map.put("phone", "17356535385");
        map.put("content", "验证码：666666");
        while (iterator.hasNext()){
            MessagePlugin messagePlugin = iterator.next();
            messagePlugin.sendMsg(map);
        }
    }
}
